if [ $# == 2 ]; then
	echo -n ""
else
	echo "usage: copycat.sh freq-th prob-th"
	exit
fi

FREQ_TH=$1
PROB_TH=$2
echo $FREQ_TH $PROB_TH

COPYCAT=../../../bin/copycat

################################
LANG=`cat ../info/lang.var`
if [ ${LANG} == "ek" ]; then

	EVAL=`cat ../info/num-eval.var`
	EVAL2=`cat ../info/num-eval2.var`
	EVALCOL=`cat ../info/num-evalcol.var`
	DEV=`cat ../info/num-dev.var`
	TRAIN=`cat ../info/num-train.var`
	COPYOPT=`cat ../info/copyopt.var`

	let TMP1=($EVAL+$EVAL2)
	let TMP2=($EVAL+$EVAL2+$EVALCOL)
	let TMP3=($EVAL+$EVAL2+$EVALCOL+$DEV)
	let TMP4=($EVAL+$EVAL2+$EVALCOL+$DEV+$TRAIN)

else
	EVAL=`cat ../info/num-eval.var`
	DEV=`cat ../info/num-dev.var`
	TRAIN=`cat ../info/num-train.var`
	COPYOPT=`cat ../info/copyopt.var`

	let TMP1=($EVAL)
	let TMP3=($EVAL+$DEV)
	let TMP4=($EVAL+$DEV+$TRAIN)
fi


################################
# DO!!
rm -rf copycat; mkdir -p copycat
${COPYCAT} ${COPYOPT} ${FREQ_TH} ${PROB_TH}  copycat-train corpus/src-all.parse corpus/src-all.tok copycat > log


###############################
# split
cd copycat
ln -s ../../i0/corpus/tgt* .
if [ ${LANG} == "ek" ]; then

	head -${EVAL} src.SP                       > src-eval.tok
	head -${TMP1} src.SP    | tail -${EVAL2}   > src-eval2.tok
	head -${TMP2} src.SP    | tail -${EVALCOL} > src-evalcol.tok
	head -${TMP3} src.SP    | tail -${DEV}     > src-dev.tok
	head -${TMP4} src.SP    | tail -${TRAIN}   > src-train.tok

	head -${EVAL} src.parse                    > src-eval.parse
	head -${TMP1} src.parse | tail -${EVAL2}   > src-eval2.parse
	head -${TMP2} src.parse | tail -${EVALCOL} > src-evalcol.parse
	head -${TMP3} src.parse | tail -${DEV}     > src-dev.parse
	head -${TMP4} src.parse | tail -${TRAIN}   > src-train.parse
	cat src-eval.parse src-eval2.parse src-evalcol.parse src-dev.parse src-train.parse > src-all.parse

	head -${EVAL} src.rinfo                    > src-eval.rinfo
	head -${TMP1} src.rinfo | tail -${EVAL2}   > src-eval2.rinfo
	head -${TMP2} src.rinfo | tail -${EVALCOL} > src-evalcol.rinfo
	head -${TMP3} src.rinfo | tail -${DEV}     > src-dev.rinfo
	head -${TMP4} src.rinfo | tail -${TRAIN}   > src-train.rinfo
else
	head -${EVAL} src.SP                       > src-eval.tok
	head -${TMP3} src.SP    | tail -${DEV}     > src-dev.tok
	head -${TMP4} src.SP    | tail -${TRAIN}   > src-train.tok
	ln -s `pwd`/src.SP ./src-all.tok

	head -${EVAL} src.parse                    > src-eval.parse
	head -${TMP3} src.parse | tail -${DEV}     > src-dev.parse
	head -${TMP4} src.parse | tail -${TRAIN}   > src-train.parse
	ln -s `pwd`/src.parse ./src-all.parse

	head -${EVAL} src.rinfo                    > src-eval.rinfo
	head -${TMP3} src.rinfo | tail -${DEV}     > src-dev.rinfo
	head -${TMP4} src.rinfo | tail -${TRAIN}   > src-train.rinfo
	ln -s `pwd`/src.rinfo ./src-all.rinfo

fi
